package com.hfh.pattern;

/**
 * @Author hfh
 * @Date 2022 09 16 14 22
 **/
public class CoffeeStore {
    public Coffee orderCoffee(String type){
        //声明Coffee类型的变量，根据不同类型创建不同coffee子类对象
        Coffee coffee=null;
        if("american".equals(type)){
            coffee=new AmericanCoffee();
        }else if("latte".equals(type)){
            coffee=new LatterCoffee();
        } else if("cappuccino".equals(type)){
            coffee=new CappuccinoCoffee();
        }else {
            throw new RuntimeException("对不起,您所点的caffe没有了");
        }

        coffee.addMilke();
        coffee.addsugar();
        return coffee;
    }

}
